package org.gdsdxy.pmmp.web.action;

import java.util.Date;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.gdsdxy.pmmp.entity.MemberBaseInfo;
import org.gdsdxy.pmmp.service.IUserManagerService;
import org.gdsdxy.pmmp.web.form.RegisterForm;

public class RegisterController extends Action {
	
	private IUserManagerService service;
	
	public void setService(IUserManagerService service) {
		this.service = service;
	}

	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest req, HttpServletResponse resp) throws Exception {
		RegisterForm regForm = (RegisterForm)form;
		MemberBaseInfo baseInfo = new MemberBaseInfo();
    baseInfo.setAnimal_sign(regForm.getAnimal_sign());
    baseInfo.setBirthday(regForm.getBirthday());
    baseInfo.setBlood_type(regForm.getBlood_type());
    baseInfo.setCareer(regForm.getCareer());
    baseInfo.setConstellation(regForm.getConstellation());
    baseInfo.setCreatetime(new Date());
    baseInfo.setEducation(regForm.getEducation());
    baseInfo.setEmail(regForm.getEmail());
    baseInfo.setEthnicity(regForm.getEthnicity());
    baseInfo.setGrad_school(regForm.getGrad_school());
    baseInfo.setMobile_phone(regForm.getMobile_phone());
    baseInfo.setNow_address(regForm.getNow_address());
    baseInfo.setPassword(regForm.getPassword());
    baseInfo.setQQ(regForm.getQQ());
    baseInfo.setRealName(regForm.getRealName());
    baseInfo.setSalary(regForm.getSalary());
    baseInfo.setSex(regForm.getSex());
    baseInfo.setSpecial(regForm.getSpecial());
    baseInfo.setStature(regForm.getStature());
    baseInfo.setUserName(regForm.getUserName());
		//BeanUtils.copyProperties(baseInfo, regForm);
		boolean registerSuccess = service.addMemberBaseInfo(baseInfo);
		String view = "";
		if(registerSuccess){
			view = "success";
		}else{
			view = "fail";
		}
		return mapping.findForward(view);
	}
}
